function hello(name:string):void{
	console.log('hello',name)
}
hello('jinyq');

type GetName = (firstName:string,lastName:string) => string;

let getName: GetName = function (firstName:string, lastName:string):string{
	return firstName+lastName
}
function print(name:string, age?:number):void{
	console.log('print',name)
}
print('mockjs');

function ajax(url:string,method:string='GET'){
	console.log(url,method)
}
ajax('/getUserInfo');

function sum(...numbers:number[]){
	return numbers.reduce((val,item)=>val+=item,0)
}
console.log(sum(1,2,3))
//函数重载
let obj:any ={}
/**
 * 如果传的val是一个字符串给obj.name
 * 数字 obj.age
 */
function attr(val:string):void
function attr(val:number):void
function attr(val:any):void{
	if(typeof val === 'string'){
		obj.name = val
	}else if(typeof val === 'number'){
		obj.age = val
	}
}
